<html ng-app="app">
<head>
<link href="../../build/common/ngEdit.css" rel="stylesheet">
<script type="text/javascript" src="../../build/common/ngEdit.js"></script>
<script type="text/javascript">

	var app = angular.module("app", [ 'base']);
	app.controller('ctrl', [ '$scope', 'baseService',function($scope, baseService) {
		$scope.data = window.passData;
		
		$scope.data.source = 'spec';
		
		$scope.user = {};
		$scope.user.list = [];
		// 指定人员
		if ($scope.data.source == 'spec' && $scope.data.userName != "") {
			$scope.user.name = $scope.data.userName;
			$scope.user.account = $scope.data.account;
			if($scope.user.name){
				var arrName = $scope.user.name.split(',');
				var arrAccount = $scope.user.account.split(',')
				$.each(arrName,function(i,item){
					var item={name:arrName[i],account:arrAccount[i]};
					$scope.user.list.push(item);
				})
			}
		}

		$scope.userDialog = function() {
			var callBack = function(data, dialog) {
				$scope.$apply(function() {
					$scope.user = {};
					$scope.user.list = data;
					$scope.user.id = "";
					$scope.user.name = "";
					$scope.user.account = "";
					$(data).each(function() {
						if ($scope.user.id) {
							$scope.user.id += ",";
							$scope.user.name += ",";
							$scope.user.account += ",";
						}
						$scope.user.id += this.id;
						$scope.user.name += this.name;
						$scope.user.account += this.account;
					});
				});
				$.Dialog.close(dialog);
			};
			
			CustUtil.openCustDialog("userSelector",callBack,$scope.user.list);
		};
	} ]);

	function getResult() {
		var scope = AngularUtil.getScope();

		//指定人员
		if (scope.data.source == 'spec') {
			scope.data.userName = scope.user.name;
			scope.data.account = scope.user.account;
		}

		if (scope.data.source == 'start') {
			scope.data.description="发起人";
		}else if (scope.data.source == 'spec') {
			if(!scope.user.name){
				$.Toast.error("请选择用户！");
				return false;
			}
			scope.data.description=""+scope.user.name;
		}
		return scope.data;
	}
</script>
</head>
<body ng-controller="ctrl">
<div id="tempTree"></div>
	<table class="form-table" cellspacing="0">
		<!-- <tr>
			<th>
				<span>用户：</span>
			</th>
			<td>
				<input type="radio" ng-model="data.source" value="spec" id="source_spec" checked="checked">
				<label class="normal_label" for="source_spec">指定用户</label>
			</td>
		</tr> -->
		<tr ng-show="data.source=='var'">
			<th>
				<span>变量选择：</span>
			</th>
			<td>
				<a class="btn btn-primary btn-xs" title="表单变量" id="asdf" onclick="showFlowMenu(this)">表单变量</a>
               </br>
               <textarea id="vars"  style="width:300px;height:30px;" ng-model="data.var.name" rows="" cols=""></textarea>
			</td>
		</tr>
		<tr ng-show="data.source=='spec'">
			<th> 指定用户： 
			</th>
			<td>
				<textarea ng-model="user.name"  readonly="readonly"  cols="30" rows="3"></textarea>
				<a href="javascript:javaScript:void(0)" class="btn  btn-primary" ng-click="userDialog()">选择用户</a>
			</td>
		</tr>
	</table>
</body>
</html>


